//
//  PrevueTableViewCell.m
//  Streaming
//
//  Created by 韩一博 on 15/6/29.
//  Copyright (c) 2015年 liuxun. All rights reserved.
//

#import "PrevueTableViewCell.h"

@implementation PrevueTableViewCell

- (void)dealloc
{
    [self.nameLabel release];
    [self.titleLabel release];
    [self.photoImageView release];
    [self.smallImageView release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        if (WIDTH == 320 && HEIGHT == 568) {
            [self create5];
        }
        if (WIDTH == 414 && HEIGHT == 736) {
            [self createPlus];
        }
        if (WIDTH == 375 && HEIGHT == 667){
            [self create6];
        }

    }
    return self;
}

- (void)create5
{
    self.photoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, (self.frame.size.width - 10) / 2 - 30, 2 * self.frame.size.height - 10)];
    [self.photoImageView setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.photoImageView];
    
    self.smallImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width - 40, self.photoImageView.frame.origin.y + self.photoImageView.frame.size.height - 40, 30, 30)];
    self.smallImageView.image = [UIImage imageNamed:@"iconfont-bofang-2.png"];
    [self.photoImageView addSubview:self.smallImageView];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width + 5, 10, (self.frame.size.width + 40) / 2, self.frame.size.height - 10)];
    [self.titleLabel setBackgroundColor:[UIColor whiteColor]];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
    [self.contentView addSubview:self.titleLabel];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width + 5, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 10, (self.frame.size.width + 40) / 2, self.frame.size.height - 10)];
    [self.nameLabel setBackgroundColor:[UIColor whiteColor]];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
    self.nameLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.nameLabel];
    
    [self.nameLabel release];
    [self.titleLabel release];
    [self.photoImageView release];
    [self.smallImageView release];
    
}


- (void)create6
{
    self.photoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, (self.frame.size.width - 10) / 2, 2 * self.frame.size.height - 10)];
    [self.photoImageView setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.photoImageView];
    
    self.smallImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width - 40, self.photoImageView.frame.origin.y + self.photoImageView.frame.size.height - 40, 30, 30)];
    self.smallImageView.image = [UIImage imageNamed:@"iconfont-bofang-2.png"];
    [self.photoImageView addSubview:self.smallImageView];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width + 10, 10, (self.frame.size.width + 40) / 2, self.frame.size.height - 10)];
    [self.titleLabel setBackgroundColor:[UIColor whiteColor]];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
    [self.contentView addSubview:self.titleLabel];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width + 10, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 10, (self.frame.size.width + 40) / 2, self.frame.size.height - 10)];
    [self.nameLabel setBackgroundColor:[UIColor whiteColor]];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
    self.nameLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.nameLabel];
    
    [self.nameLabel release];
    [self.titleLabel release];
    [self.photoImageView release];
    [self.smallImageView release];
    
}

- (void)createPlus
{
    self.photoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, (self.frame.size.width - 10) / 2, 2 * self.frame.size.height - 10)];
    [self.photoImageView setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.photoImageView];
    
    self.smallImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width - 40, self.photoImageView.frame.origin.y + self.photoImageView.frame.size.height - 40, 30, 30)];
    self.smallImageView.image = [UIImage imageNamed:@"iconfont-bofang-2.png"];
    [self.photoImageView addSubview:self.smallImageView];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width , 10, 300, self.frame.size.height - 10)];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [self.titleLabel setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.titleLabel];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.origin.x + self.photoImageView.frame.size.width + 10, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 10, 300, self.frame.size.height - 10)];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
    self.nameLabel.textColor = [UIColor lightGrayColor];
    [self.nameLabel setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.nameLabel];
    
    [self.nameLabel release];
    [self.titleLabel release];
    [self.photoImageView release];
    [self.smallImageView release];
    
}

- (void)setPrevue:(Prevue *)prevue
{
    if (_prevue != prevue) {
        [_prevue release];
        _prevue = [prevue retain];
    }
    NSURL *url = [NSURL URLWithString:prevue.coverImg];
    [self.photoImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"111111.png"]];
    self.titleLabel.text = prevue.movieName;
 
    
    self.nameLabel.text = prevue.summary;
    
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
